Repository navigation
fix(durable): replay an actor's done data and errors as the live run delivered them - #268
Conversation
Review findingsThe AI reviewers' pass over this change checked every review label and found no blockers in
|
e49c94b to
3687520
Compare
3687520 to
23391d7
Compare
Decisions for Temple to ratifyI made these calls in this PR. Each is a suggestion for you to confirm or change.
|
6d3453d to
889d948
Compare
…delivered them An actor's done data reached the parent as the behavior's own Go value on the live run and as JSON's generic form on replay, so a parent reducer saw two shapes for one transition (#256): an order live, a map after Recover. An actor's error kept its raw message live and the U+FFFD-replaced one a Store keeps on replay, and an error whose Error method panics — a typed nil, which a host's own ActorInstance can settle with — crashed the host through the journal's Error() call. - state: ActorSystem.WithSettleTransform rewrites every actor outcome before it settles, whether a delivery, a panic the actor raised while stepping, or SettleError settles it, mirroring ServiceRunner.WithResultTransform: it gets the event that will carry the outcome and runs before the actor is marked done and before the routing Fire. A non-nil abort fires nothing and leaves the actor running, reported as the ServiceRunner's abort is. - durable: the Runner settles its actors through the transform the service seam uses (#258's replayableOutcome, generalized to name its outcome), so an actor's done data decodes through WithEventDataDecoder for the parent's onDone event, live as on replay; an error is message-only, normalized; and one whose Error method panics settles with a message saying so. The journal records the JSON the live settle decoded with the done data's Go type, in actor entries, and replay holds the decoder to that type, as a recorded service result's replay does. - durable: there is no parking for an actor outcome, as a service result that won't decode has. Done data that won't decode, or decodes as another type than the actor produced, aborts the settle, fires nothing, and fails the Handle — the delivery, or the Fire, Tick or RunService whose absorb drove the settle — recording nothing, so the actor runs again on Recover. Start and Recover fail the same way when a settle their spawns drive aborts. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…eliver's abort A settle whose WithSettleTransform function ran while the actor was stopped and spawned again under the same id settled the new actor with the old outcome, or reported its abort as though the new actor were the one the transform ran for. The settle now holds to the *runningActor it began for, still running: when the actor under the id is another one it returns false, fires nothing, and reports no abort, leaving the new actor running, as the ServiceRunner's stale settle does for a re-armed activation. A deterministic test drives the respawn from inside the transform — the supervisor leaves supervising and re-enters it, which stops the child and spawns a fresh one under the same id — and mutation-checks both branches: dropping either identity check fails it. - state: Deliver's and WithSettleTransform's documentation now say an abort from a settle a delivery drives isn't reported to Deliver's caller: Deliver returns only whether it found the actor running, so the actor stays running and the host sees the abort by calling Tick or SettleError itself; the durable Runner reports it through the Handle. - durable: the type check a replay holds a recorded outcome to (decodedAsRecorded) now takes the outcome's name the way decodedAsPassed does, so an actor's done-data a Recover's decoder returns as another type fails saying "actor done-data", not "service result". Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
An actor's done-data is held to the Go type the live settle recorded, so the rename concern WithResultTypeAlias answers for service results applies to it: a pure refactor that moves or renames the type failed Recover and StateAt for every journal already settled under the old name, with no way to tell the Runner what the recorded name now means. The alias now covers actor done-data on every replay path — Recover from the journal, Recover from a checkpoint's tail, and StateAt — through the same replayableOutcome transform the live settle and a recorded service result's replay use, with no new exported API: the option's doc comment now says it covers both outcomes. A decoder that returns the aliased type settles the done-data, and every other recorded name is held to strictly, exactly as before. The refusal wording matches a recorded service result's, naming the done-data and, when an alias covers the name, the aliased type to decode as. Tests cover Recover and StateAt from the journal and a Recover from a checkpoint whose compacted tail holds the settle, in the style of TestResultTypeAlias_RenamedSettledResult, and are mutation-checked: dropping the alias lookup on the actor path fails them. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…ill in the review's docs and probe The settle transform ran for every settle, routed or not, so an actor spawned with no onDone for its outcome — a dynamic spawn; an invoked actor always routes, firing the zero event its unset outcome leaves — whose Output() won't encode aborted a settle that would otherwise have been the fire-and-forget no-op it is without the transform, failing the delivery's Handle for an outcome nothing consumes. The transform now runs only when the settle routes a completion, to the invocation's onDone for a success or its onError for a failure; a settle that routes nothing runs no transform, aborts nothing, fires nothing, journals nothing, and LastOutput and LastError keep the raw outcome, exactly as on main. The staleness checks are unchanged. The docs claimed a host could see a delivery-driven abort by calling Tick after it; it can't, because the delivery drained the mailbox, so that Tick returns early. The Deliver doc, the WithSettleTransform doc and state's CHANGELOG now say the abort is never recoverable through Deliver: it's visible only to a host that drives Tick itself, or through SettleError, and the durable Runner's Handle, which reports it, is the intended channel. WithEventDataDecoder's doc gains the actor done-data paragraph its README and doc.go already carry, and durable's actor docs note the unrouted rule. New tests pin the unrouted settle as a no-op in state — no transform call for an output that won't encode, for the zero event an onDone-less settle would hand a decoder that refuses it, or for a failure, which escalates as without the transform — and through durable, where the channeled output settles without failing the Handle and Recover and StateAt replay the run, and a decoder that refuses the zero event is never consulted. A probe drives one Fire whose absorb finishes two actors with distinct done data and asserts each journal entry's Data and Type and each onDone Assign's value, live, after Recover and through StateAt, catching a swapped or dropped settle relay. Both are mutation-checked: the transform back ahead of the route check turns the unrouted tests red, and a one-behind settle slot turns the probe red. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
23391d7 to
681f0ef
Compare
Decisions for Temple to ratifyI made these calls in this PR. Each is a suggestion for you to confirm or change.
|
joshua-temple
left a comment
There was a problem hiding this comment.
Medium-to-critical findings, each reproduced with a probe test on this head (681f0ef). Inline comments carry the detail.
- 1 High:
service.go:285re-runs a ServiceFn after an actor abort - 10 Medium:
state/actor_system.go(6),durable/runner.go(2), test and CHANGELOG (2) - 1 stale doc outside the diff:
docs/src/content/docs/durable/overview.md:168still says a reducer observes the JSON-decoded shape on replay; the PR removed that caveat fromdurable/README.mdanddoc.goonly - Suite is green under
-raceand-shuffle; the gaps are untested branches and the cases above
joshua-temple
left a comment
There was a problem hiding this comment.
Review summary (medium and above only):
- High: an InvokeActor with no onDone counts as routed (zero event), so its success now consults the decoder and can fail the Handle. It worked on main.
- High (same root): pre-PR journals with that refused zero-event settle now fail Recover under a strict decoder.
- Medium:
WithSettleTransformaborts are dropped on the sendTo/Deliver path for any non-durable host. - Probe: a strict decoder plus
InvokeActor("kid", WithInvokeOnError("childFail")), thenDeliverToActorByID("finish"). On main it returnstrue, nil. On this branch it returns ErrHandleFailed (actor done-data won't decode for event : no payload expected for event ""). - Unrouted coverage uses only the
Spawnaction (quietMachine,unroutedParentMachine), which leaves OnDone nil. So it skips the invoked-actor shape. go test -raceis green for state and durable at 681f0ef.
|
Test gap: please add coverage for the unrouted settle on an
|
|
Follow-up: I ran a probe test for each finding in the review above, against main and against 681f0ef. All three hold, there are no new findings, and nothing needs correcting. 1. High: an invoked actor with no onDone now fails the Handle under a strict decoder (
2. High: a journal written on main fails Recover on this branch (
Probe for 1 and 2: durable/zz_invoke_probe_test.gopackage durable_test
import (
"context"
"fmt"
"os"
"testing"
"github.com/stablekernel/crucible/durable"
"github.com/stablekernel/crucible/state"
)
type zzCtx struct {
Notes []string `json:"notes"`
}
type zzOrder struct{ ID int }
// zzChild completes with output once delivered "finish".
func zzChild(output any) state.ActorBehavior {
return func(map[string]any) (state.ActorInstance, error) {
child := state.ForgeFor[zzCtx]("child").
State("working").State("done").Final().Initial("working").
Transition("working").On("finish").GoTo("done").Quench()
inst := child.Cast(zzCtx{}, state.WithInitialState[string]("working"))
return state.NewActor(inst, func(*state.Instance[string, string, zzCtx]) any { return output }), nil
}
}
// zzMachine invokes kid with an onError only: no WithInvokeOnDone.
func zzMachine() *state.Machine[string, string, zzCtx] {
return state.ForgeFor[zzCtx]("zz").
State("idle").
State("supervising").InvokeActor("kid", state.WithInvokeOnError("childFail")).
State("failed").
Initial("idle").
Transition("idle").On("start").GoTo("supervising").
Transition("supervising").On("childFail").GoTo("failed").
Transition("supervising").On("poke").GoTo("supervising").
Quench()
}
// zzOpts wires kid and a strict decoder that knows only childFail's payload.
func zzOpts() []durable.Option[string, string, zzCtx] {
return []durable.Option[string, string, zzCtx]{
durable.WithActorPalette[string, string, zzCtx](map[string]state.ActorBehavior{"kid": zzChild(zzOrder{ID: 7})}),
durable.WithEventDataDecoder[string, string, zzCtx](func(e string, data []byte) (any, error) {
if e == "childFail" {
return durable.DecodeAs[any](data)
}
return nil, fmt.Errorf("no payload expected for event %q", e)
}),
}
}
var zzKid = state.ActorID("zz", "supervising", 0)
// drive starts the instance, enters supervising and finishes kid; it returns the
// delivery's error and a follow-up Fire's.
func zzDrive(t *testing.T, store durable.Store, opts []durable.Option[string, string, zzCtx]) (error, error) {
t.Helper()
ctx := context.Background()
h, err := durable.NewRunner(zzMachine(), store, opts...).Start(ctx, "zz", zzCtx{}, state.WithInitialState("idle"))
if err != nil {
t.Fatalf("Start: %v", err)
}
if _, err := h.Fire(ctx, "start"); err != nil {
t.Fatalf("Fire start: %v", err)
}
_, derr := h.DeliverToActorByID(ctx, zzKid, "finish")
_, ferr := h.Fire(ctx, "poke")
return derr, ferr
}
// Finding 1: the onDone-less success of an invoked actor must not fail the Handle.
func TestZZ1_InvokedActorWithoutOnDone_StrictDecoder(t *testing.T) {
derr, ferr := zzDrive(t, durable.NewMemStore(), zzOpts())
if derr != nil || ferr != nil {
t.Fatalf("DeliverToActor = %v; Fire after = %v; want both nil, as on main", derr, ferr)
}
}
// Finding 2, phase 1 (run on main): journal the onDone-less settle to a FileStore.
// Phase 2 (run on the PR head): Recover that journal under the same strict decoder.
func TestZZ2_OldJournal_RecoverUnderStrictDecoder(t *testing.T) {
dir := os.Getenv("ZZ_DIR")
if dir == "" {
t.Skip("set ZZ_DIR")
}
store, err := durable.NewFileStore(dir)
if err != nil {
t.Fatalf("NewFileStore: %v", err)
}
if os.Getenv("ZZ_PHASE") == "write" {
if derr, ferr := zzDrive(t, store, zzOpts()); derr != nil || ferr != nil {
t.Fatalf("writing the journal: %v, %v", derr, ferr)
}
return
}
if _, err := durable.Recover(context.Background(), zzMachine(), store, "zz", zzOpts()...); err != nil {
t.Fatalf("Recover of the main-written journal = %v; want nil, as on main", err)
}
}Run: 3. Medium: a WithSettleTransform abort on the Deliver path reaches no caller (
Probe for 3: state/zz_abort_probe_test.go (uses settleHarness from settle_transform_test.go)package state_test
import (
"context"
"errors"
"testing"
"github.com/stablekernel/crucible/state"
)
// Finding 3: an abort from a settle a Deliver drives reaches no caller.
func TestZZ3_SettleTransformAbort_DroppedByDeliver(t *testing.T) {
ctx := context.Background()
parent, sys, id := settleHarness(t, func(string, any, error) (any, error, error) {
return nil, nil, errors.New("won't record")
})
var fired int
sys.WithParentFireObserver(func(state.ParentFire[string]) { fired++ })
var inspected []state.InspectionEvent
sys.WithActorInspector(state.InspectorFunc(func(ev state.InspectionEvent) { inspected = append(inspected, ev) }))
ref, _ := sys.Ref(id)
found := sys.Deliver(ctx, ref, "finish")
later := sys.Tick(ctx, id)
t.Logf("Deliver=%v fired=%d parent=%q running=%v laterTick=%d inspectorEvents=%d",
found, fired, parent.Current(), sys.IsRunning(id), len(later), len(inspected))
if found && fired == 0 && sys.IsRunning(id) && len(later) == 0 {
t.Fatal("the abort was dropped: Deliver reported success, nothing fired, the actor is stuck running, and a later Tick returns nothing")
}
}Run: Candidate I ran and dropped
|
…invoke declared An InvokeActor with no WithInvokeOnDone counted as routed: invokeOutcome boxes the zero event, so the spawn's e.OnDone.(E) always succeeded and hasDone was true for every invoked actor. A success with no onDone then ran the settle transform and consulted the event-data decoder for the zero event before the parent refused it, so a strict per-event decoder failed the Handle — DeliverToActor, Fire and Tick, live and again after every Recover — where main journaled a refused fire and kept going. The same held for a failure with no onError, and for a spawn that failed to start: the zero event fired where a dynamic spawn escalates. The invocation IR now records HasOnDone / HasOnError, set only when the option was given, and SpawnActor carries HasDone / HasError from the invoke options or the spawn params' presence, so the ActorSystem routes on what was declared rather than on the zero event an unset outcome leaves: a success with no onDone settles as the fire-and-forget no-op a dynamic spawn's always was, and a failure or failed spawn with no onError escalates, as a dynamic spawn's does. The Invocation fields are additive omitempty wire fields appended to the frozen shape; services are untouched, and a spawn that declares the zero event itself still routes it. Replay compat: a journal a version before this change wrote can hold a refused settle — the zero-event settle of an onDone-less invoke — with its done-data recorded and no type. Replay now never decodes the data of a fire whose replay will be refused; it re-fires the recorded event plainly and meets the same refusal, so Recover and StateAt succeed on those histories under a strict decoder, as they did on main. New tests pin each half: the invoked-actor unrouted settle in state (no transform call for the undeclared outcome, success a no-op, failure escalated, a failed spawn never caught by a zero-event transition) and through durable (Temple's probe as a permanent test: a strict decoder, InvokeActor with only onError, the delivery and the follow-up Fire both healthy, live and after Recover); and the replay compat case, journal built in-test by rewriting a record to drop the recorded type, in the style of the alias tests' rewrite harness. All are red on the parent commit. The two skipped #250 probes that the zero-event firing blocked are unskipped — a failed no-onError spawn now escalates, so a transition on the zero event never catches it and Recover retries the spawn — and the declared-but-unroutable onError case keeps its skip with the reason narrowed to the ErrNoTransition stopgap it actually is. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…sorb aborts on The High of the review's second pass: when a service's settle drove an actor whose own settle aborted in the same step, takeAborts failed the step and recorded nothing — including the service's own result, which had run and decoded. Recover left the service in flight, so RunService ran the ServiceFn again, and the abort recurred on every retry: three attempts, three runs, non-idempotent work (a payment) repeating. That contradicted the parking design's "never runs again" promise, which the comment beside the check and the RunService doc both leaned on. serviceStep now journals the service's settle — and the parent Fires the settle's absorb drove before the abort, which applied live — before it fails the Handle on the actor's abort. On Recover the service's settle replays from the journal, so the ServiceFn never runs again, however many Recover-and-retry rounds follow; only the actor re-runs, from its initial state, on each Recover's respawn of the still-running actor and on each redelivery. The Fire, Tick and DeliverToActor ends keep recording nothing: no service result is theirs to lose, and re-firing the event re-drives the actor. The new test drives fetch's onDone into a state that spawns a poker whose message to the parent finishes kid, whose done-data a strict decoder refuses, and walks three Recover-and-retry rounds: the first RunService settles fetch and fails on the aborted settle, and every later RunService finds fetch settled in the journal and runs nothing, while each redelivery fails on the actor alone. It is red on the parent commit — three ServiceFn runs. The RunService row of the undecodable- settle table is updated to the new contract, and its Fire and Tick rows still pin recording nothing. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…the actor one settle at a time The Medium of the review's second pass, and the review's first-pass concurrency finding: abort reporting was Tick-only, but Tick's results are dropped by every delivery path — deliver, the sendTo / sendParent / respond / forwardTo sugar through dispatch, and Deliver — so a non-durable host on the transform got a silent abort, the actor stuck running with a final machine and an empty mailbox, and durable knew only through its own side channel, which noted aborts even for settles the system then suppressed as stale. The new ActorSystem.WithSettleAbortObserver — modeled on WithParentFireObserver — is called once for every settle that aborts, on every path that drives one, with a SettleAbort: the actor's id, the event the settle would have carried the outcome through, and the abort itself. It is the one channel a delivery's abort reaches, and the report is made only after the settle has rechecked its actor under the system lock, so a stale settle reports nothing. Durable wires it in place of the transform wrapper's own noting, which simplifies parentFires.aborted and stops noting aborts the system suppresses. One settle now owns the actor it settles, from its entry to its return: a settle that finds the actor already settled — SettleError on an already-settled, not-stopped actor is refused where it re-settled on main; that refusal gains a CHANGELOG line — or owned by a settle still in flight, another goroutine's or the transform's own reentrant call, returns the zero result and false, running no second transform against the winner's outcome, so a losing concurrent settle reports nothing, fires nothing and never overwrites the winner's recorded JSON. A Tick whose step produced the actor's real completion waits the owner out rather than dropping it, and a delivery whose actor is owned leaves its envelope queued for a later Tick. The -race test drives two concurrent settles on one id — a delivery's success and an aborting SettleError — and the reentrancy test pins the refusal a transform's own nested settle gets. Two more of the review's findings ride along in settle. The respawn drop (hearing) is now decided before the transform runs, so a settle a host's respawn replay throws away consults no decoder and can't abort on an outcome that differs on the respawn — Recover no longer fails for a dropped settle whose respawned child outputs something that won't encode. And a failure the transform rewrote into a success nothing routes escalates the ORIGINAL error, as the failure does with no transform: a transform may rewrite the outcome, not erase the failure — the escalation, LastOutput and LastError all pinned by new tests, with the UnboundActorError keep and the settled-actor refusal pinned too. Every new test is red on the parent commit where it can be: the vanishing failure, the respawn drop, and the observer tests (the API itself absent); the refusal and keep tests pin behavior the parent already had. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
The rest of the review's medium findings, as pins and doc corrections, no behavior change: - A panicking actor's aborted settle: Tick's panic branch returns the abort as its one FireResult and reports it to the observer, as the done branch's test already pinned — killing the two `ok || res.Err != nil` mutants the review's mutation run left alive. - Start's aborted settle: the baseline checkpoint is already written, so a retry Start returns ErrInstanceExists and the retry is a Recover from the baseline, which re-runs the spawns; the Start comment, doc.go and fireStep now say so, and fireStep's says an actor the Fire's own transition spawned isn't respawned by the Recover that restores the pre-event state. Both pinned: the retry-Start test counts the spawn runs across the attempts, and the Fire's-own-spawn test proves the recovered Handle doesn't run the dynamic spawn and re-firing the event is what runs it again. - Panic wording pinned exactly: an actor error whose Error method panics settles with "actor error panicked: <recovered>", live and on replay, and a done-data with no JSON form fails the Handle with "actor done-data won't encode: <why>" — the actor seam's own words, so swapping them for the service seam's turns the tests red. - The Start end's StateAt now compares its notes to the live run's, as the Fire, Tick and RunService ends' do, not just its error. - durable's Changed entry on actor done-data decoding now says plainly what changes for callers reading AssignCtx.Event — without a decoder a struct arrives as a map, and errors are message-only so errors.Is and errors.As stop matching — and that WithEventDataDecoder is the opt-out. The move out of Added happened at 681f0ef; this finishes it. - The stale line in docs/durable/overview.md that still said a reducer sees the JSON-decoded shape only on replay now matches the README and doc.go: the done-data gets the same decode live as on replay. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
|
Medium: when a
Probe: state/zz_flip_probe_test.go (uses settleChildBehavior and trec from the package tests)package state_test
import (
"context"
"errors"
"testing"
"github.com/stablekernel/crucible/state"
)
// flip turns every failure into a success, as WithSettleTransform's doc allows.
func flip(_ string, _ any, err error) (any, error, error) {
if err != nil {
return "recovered", nil, nil
}
return nil, nil, nil
}
func zzFlipRun(t *testing.T, name string, build func(*state.Builder[string, string, *trec]) *state.Builder[string, string, *trec], id string) {
ctx := context.Background()
b := state.ForgeFor[*trec](name).State("idle")
m := build(b).
State("done").State("failed").
Initial("idle").
CurrentStateFn(func(*trec) string { return "idle" }).
Transition("supervising").On("childDone").GoTo("done").
Transition("supervising").On("childErr").GoTo("failed").
Quench()
parent := m.Cast(&trec{}, state.WithInitialState[string]("idle"))
sys := state.NewActorSystem(parent).Register("child", settleChildBehavior()).WithSettleTransform(flip)
var fired []string
sys.WithParentFireObserver(func(pf state.ParentFire[string]) { fired = append(fired, pf.Result.Trace.Event) })
sys.Absorb(ctx, parent.Fire(ctx, "start").Effects)
if id == "" {
id = state.ActorID(name, "supervising", 0)
}
res, ok := sys.SettleError(ctx, id, errors.New("boom"))
t.Logf("%s: ok=%v resErr=%v fired=%q parent=%q running=%v escalation=%v lastErr=%v",
name, ok, res.Err, fired, parent.Current(), sys.IsRunning(id), sys.LastEscalation() != nil, sys.LastError())
}
func TestZZFlip(t *testing.T) {
zzFlipRun(t, "both", func(b *state.Builder[string, string, *trec]) *state.Builder[string, string, *trec] {
return b.State("supervising").InvokeActor("child", state.WithInvokeOnDone("childDone"), state.WithInvokeOnError("childErr")).
Transition("idle").On("start").GoTo("supervising")
}, "")
zzFlipRun(t, "invokeErrOnly", func(b *state.Builder[string, string, *trec]) *state.Builder[string, string, *trec] {
return b.State("supervising").InvokeActor("child", state.WithInvokeOnError("childErr")).
Transition("idle").On("start").GoTo("supervising")
}, "")
zzFlipRun(t, "spawnErrOnly", func(b *state.Builder[string, string, *trec]) *state.Builder[string, string, *trec] {
return b.State("supervising").
Transition("idle").On("start").GoTo("supervising").Spawn("child", "kid", state.WithSpawnOnError("childErr"))
}, "kid")
}Run: |
…JSON, and retry a settle on a finished actor The re-review's blocker and its two mediums, on the declared-outcome flags and the abort a delivery can no longer recover through stepping. An older producer's JSON — a machine serialized before Invocation.HasOnDone / HasOnError existed, or a SpawnActor effect payload from before HasDone / HasError — never wrote the flags, so a reload decoded every declared outcome as unset and the invoked actor's success settled as the fire-and-forget no-op an outcome nothing declared is: the declared onDone was lost. The loads now back-fill each flag for an outcome whose key is absent and whose event is present and non-zero — an older producer set the event only when it declared it — so a reloaded definition keeps the outcomes it declared, an unset outcome (the zero event) still routes nothing, and a new producer's serialization round-trips byte-identically, flags, goldens and TestRoundTrip_Identity unchanged. The Invocation test is typed and exact; the SpawnActor effect's field is type-erased, so its zero test is on the decoded value's own type — exact for the scalar events a wire form distinguishes — and a composite event's declared outcomes reload from the typed IR instead of an aged payload. The CHANGELOG's sentence on pre-flags serializations now says all this. A delivery or Tick to a running actor whose machine is already final — an actor a settle's transform aborted left it that way — stepped the machine anyway, firing the delivered event into the final state, which failed as "state is final" and settled the actor as a failure through onError (or an escalation): the actor's completed outcome was misrouted as a crash. It now retries settling the final outcome instead, through the same ownership path as any settle — the optional finalActor interface the standard actorAdapter implements reports the final machine — so the transform runs again, an abort is reported again to the WithSettleAbortObserver, and once the transform stops aborting a later delivery or Tick lands the good output through onDone. The retry runs with an empty mailbox too, so a bare Tick settles an outcome a delivery's abort left unsettled. Nothing is misrouted through onError. Durable is unaffected: its live deliveries drive the same settle they always did, so the journal records the same entries, and its replay never delivers to an actor. The Deliver, Tick and WithSettleTransform docs and the CHANGELOG say so, and the stale claim that an abort is never recoverable through Deliver is gone. The WithSettleAbortObserver doc's backwards sentence is fixed too: observe runs inside settle's abort branch, before the abort reaches any caller, on every path, while the settle still owns the actor. Every behavioral test is red on the parent commit: the lost onDone, from the IR and from an aged effect payload, the misrouted retry through onError, and the empty Tick that left the outcome unsettled; the byte-identity and unset-outcome tests pin what the back-fill must not disturb. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Decisions for Temple to ratify (after your reviews)These are new calls since the first decisions comment. Each is a suggestion for you to confirm or change.
|
GO-2026-6974 in go.opentelemetry.io/otel/trace is fixed in v1.47.0. The vulnerability scan fails on sink/gcppubsub, which reaches it through pubsub.Publisher.Publish. Bump otel, metric and trace (and sdk where used) to v1.47.0 in every module that pins them, then go mod tidy. govulncheck is clean in all 20 modules. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
What this does
An actor's done data and errors now replay exactly as the live run delivered them. This is the same treatment #258 gives service results.
On main, the parent's onDone
Assignsaw the actor's own Go value live, but JSON's generic form afterRecover. AnOrdercame back as amap[string]any, and anint64as afloat64. An error with invalid UTF-8 replayed with U+FFFD. An error whoseError()panics, such as a typed nil, killed the host process:failOnPanicfailed the Handle and then re-panicked.Now:
WithEventDataDecoderfor the parent's onDone event, both live and on replay. Replay holds the decoder to the Go type the live settle recorded, as feat(durable): decode service results through WithEventDataDecoder and park undecodable ones #258 does for services.WithResultTypeAliascovers a renamed done-data type the same way it covers a service result, on every replay path:Recoverfrom the journal,Recoverfrom a checkpoint, andStateAt.Error()that panics settles with a message saying so, rather than crashing the host.ErrEventDataEncodingand records nothing, and the actor runs again onRecover. Unlike a service result, an actor outcome is never parked, because nothing can re-settle an actor without running it again.New API, for the maintainer to decide
state.ActorSystem.WithSettleTransform(func(event E, output any, err error) (out any, outErr error, abort error)) *ActorSystem[S, E, C]It's the actor counterpart of the
ServiceRunner'sWithResultTransform. Every actor settle passes the outcome directly to the parent'sFire, sodurablehas no other place to make live and replay agree. The transform runs before the actor is marked done, and only when the settle routes a completion. An abort fires nothing and leaves the actor running. It's flagged instate's changelog. I'm suggesting it, not deciding it.Recorded done-data types
Actor entries now carry the done data's Go type, recorded the same way a service result's is. There's no journal format bump and no old-journal gate, because durable is greenfield.
Tests
DeliverToActor, and actors spawned duringFire,Tick,RunServiceandStart, each checked againstRecoverandStateAt.WithResultTypeAlias, through the journal and through a checkpoint.Error(), on both paths.state: the transform rewrites an outcome beforeAssignsees it. An abort fires nothing. A settle whose transform ran while the actor was stopped and respawned under the same id leaves the new actor alone.Checks
go test -race, golangci-lint and govulncheck pass in state, durable, transport, e2e and examples/dispatch (go1.27.4)stateanddurableRebased onto main after #258 and #267 merged, so it's no longer stacked.
Closes #256